import requestData from '@/utils/request';
export default {
  namespaced: true,
  state: {
    openId: '',
  },
  actions: {
    async getSensitiveData ({commit}, payload) {
      const [result, err] = await requestData({
        method: 'GET', 
        url: '/user/sensitiveData',
        data: {
          code: payload.code,
        }
      });
      if (!err) {
        commit('updateMe', { openId: result.openid });
      }
    },
    async addUser ({commit}, payload) {
      await requestData({
        url: '/user/add',
        method: 'POST',
        data: payload,
      })
    }
  },
  mutations: {
    updateMe(state, payload) {
      Object.assign(state, payload);
    }
  }
}